/**
 * 
 */
package com.demo.shiro.tag;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

/**
 * ShiroTag
 * Description:	 
 * @author Zhuqingcheng
 * @date 2017年6月21日 下午4:52:27
 */
public class ShiroTag {
	 private Subject getSubject() {
	        return SecurityUtils.getSubject();
	    }

	    public boolean isGuest() {
	        return getSubject() == null || getSubject().getPrincipal() == null;
	    }

	    public boolean hasRole(String roleName) {
	        return getSubject() != null && getSubject().hasRole(roleName);
	    }


	    public boolean lacksRole(String roleName) {
	        boolean hasRole = getSubject() != null
	                && getSubject().hasRole(roleName);
	        return !hasRole;
	    }

}
